package com.library.service.impl;

import java.util.List;

import com.library.bean.Book;
import com.library.bean.Page;
import com.library.dao.BookDao;
import com.library.dao.impl.BookDaoImpl;
import com.library.service.BookService;

public class BookServiceImpl implements BookService {

	private BookDao bookDao = new BookDaoImpl();
	@Override
	public List<Book> getAllBook() {
		return bookDao.selectAllBooks();
	}
	@Override
	public List<Book> getBooks(String keyword) {
		return bookDao.selectBooks(keyword);
	}
	@Override
	public int deleteBook(int bookId) {
		return bookDao.deleteBookById(bookId);
	}
	@Override
	public int addBook(Book book) {
		return bookDao.insertBook(book);
	}
	@Override
	public Book getBookById(int bookId) {
		
		return bookDao.selectBookById(bookId);
	}
	@Override
	public int updateBook(Book book) {
		
		return bookDao.updateBook(book);
	}
	@Override
	public Page<Book> getAllBook(int pageNum, int pageSize) {
		int totalRows = bookDao.getAllBooksNum();
		List<Book> data = bookDao.selectAllBooks(pageNum, pageSize);
		Page<Book> page = new Page(data,pageNum,pageSize,totalRows);
		return page;
	}

	
	
	
	
	

}
